<template>
  <h1>父组件</h1>
  <button @click="clickFn">外部组件调用</button>
  <hr />
  <Form ref="FormRef" />
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import Form from './components/Form.vue';

// 组件类型：<InstanceType<typeof Form>
const FormRef = ref<InstanceType<typeof Form> | null>(null);

const clickFn = () => {
  if (FormRef.value) FormRef.value.validate();
};

onMounted(() => {
  console.log('组件实例', FormRef.value);
});
</script>
